package cn.edu.imnu.Controller;

import cn.edu.imnu.Service.DoctorService;
import cn.edu.imnu.Service.SaleService;
import cn.edu.imnu.entity.Result;
import cn.edu.imnu.entity.dto.*;
import cn.edu.imnu.entity.vo.DoctorListvo;
import cn.edu.imnu.entity.vo.Doctorlevelvo;
import cn.edu.imnu.entity.vo.SaleListvo;
import cn.edu.imnu.entity.vo.TreatTypevo;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


@RestController
@ResponseBody
@RequestMapping("/doctor")
public class DoctorController {
    @Autowired
    private DoctorService doctorService;
    @PostMapping("/doctorsLocations")
    public Result getAllDoctors(@RequestBody DoctorListdto doctorListdto) {
        /*List<DoctorListvo> doctorList = doctorService.getAllDoctors(doctorListdto);*/
        DoctorListvo doctorList=doctorService.getAllDoctors(doctorListdto);
        return Result.success(doctorList);
    }

    @PostMapping("/delete")
    public Result deleteDoctor(@RequestBody Map<String, Long> requestBody) {
        Long id = requestBody.get("id");
        System.out.println("接收到的参数：" + id);
        return doctorService.deletedoctor(id);
    }
    @PostMapping("/doctorslevel")
    public Result getDoctorslevel() {
        List<Doctorlevelvo> doctorlevel = doctorService.getDoctorslevel();
        return Result.success(doctorlevel);
    }
    @PostMapping("/TreatType")
    public Result getTreatType() {
        List<TreatTypevo> treatTypevo = doctorService.getTreatType();
        return Result.success(treatTypevo);
    }
    @PostMapping("/update")
    public Result updateDoctor(@RequestBody Doctorupdatedto dto) {
        System.out.println("接收到的更新请求数据: " + dto);
        return doctorService.updateDoctor(dto);
    }
    @PostMapping("/updatepwd")
    public Result updateDoctorpwd(@RequestBody Updatepwddto dto) {
        System.out.println("接收到的更新请求数据: " + dto);
        return doctorService.updateDoctorpwd(dto);
    }
    @PostMapping("/add")
    public Result addDoctor(@RequestBody Doctoradddto dto) {
        return doctorService.addDoctor(dto);
    }

}
